package top.zxybird.demo.juc;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by zxybird on 2018/2/23.
 */
public class ThreadDemo implements Runnable {

  private boolean done = false;

  private Object result;

  @Override
  public void run() {

    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    System.out.println("Running");

    result = new Object();

    done = true;

  }

  public boolean isDone() {
    return done;
  }

  // public void setDone(boolean done) {
  // this.done = done;
  // }

  public Object getResult() {
    return result;
  }

  // public void setResult(Object result) {
  // this.result = result;
  // }

  public static void main(String[] args) {

    // Thread => ExecutorService, 一种进化

    ExecutorService executorService = Executors.newSingleThreadExecutor();

    executorService.submit(new ThreadDemo());

    // new Thread(new ThreadDemo()).start();
  }

}
